import {defineStore} from "pinia"
import {LoginDto} from "@/type/dto/LoginDto";

interface UserState {
    isLoggedIn: boolean
    userInfo: LoginDto
}

export const useUserStore = defineStore('user', {
    state: (): UserState => ({
        isLoggedIn: false,
        userInfo: {
            userId: '',
            userName: '',
            officeName: '',
            tokenId: '',
            officeCode: '',
        }
    }),
    actions: {
        login(userInfo: UserState['userInfo']) {
            this.isLoggedIn = true
            this.userInfo = userInfo
        },
        logout() {
            this.isLoggedIn = false
            this.userInfo = {
                userId: '',
                userName: '',
                officeName: '',
                tokenId: '',
                officeCode: ''

            }
        }
    },

})